﻿using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using DevExpress.XtraReports.UI;
using System.Collections.Generic;
using ConfExpert.Utility;
using System.Data;
using System.Windows.Forms;

namespace Tailord.Reports
{
    public partial class KumasSiparisFoyu : DevExpress.XtraReports.UI.XtraReport
    {

        DataSet DsFoy;
        float yukselik = 110;
        public KumasSiparisFoyu()
        {
            InitializeComponent();
        }

        public KumasSiparisFoyu(DataSet DsFoy)
            : this()
        {
            tcHeader.Text = "Kumaş Sipariş Föyü";            
            trRef.Visible = barcode.Visible = false;

            this.DsFoy = DsFoy;
            BindDstoReport(false);
        }


        //private void SetHeight()
        //{
        //    using (FoyAyarlari ayarlar = new FoyAyarlari())
        //    {
        //        ayarlar.spinner.Value = Convert.ToDecimal(yukselik) / 10;
        //        if (ayarlar.ShowDialog() == DialogResult.OK)
        //            yukselik = (float)ayarlar.spinner.Value * 10;
        //    }
        //}

        void BindDstoReport(bool Gelismis)
        {
            //if (Gelismis)
            //    SetHeight();

            barcode.ShowText = false;

            tblDetail.HeightF =  yukselik;
            Detail.HeightF =  yukselik;


            DataRow drFoyHeader = DsFoy.Tables[0].Rows[0];
            //DataRow drToplamMetre = DsFoy.Tables[2].Rows[0];

            //tcToplam.Text =  drToplamMetre["ToplamMetre"].ToString();

            tcSiparisiOlusturan.Text = drFoyHeader["SiparisiOlusturan"].ToString();
            tcSiparisNo.Text = drFoyHeader["SiparisNo"].ToString();
            tcSiparisTarihi.Text = drFoyHeader["SiparisTarihi"].ToString();
            tcNot.Text = drFoyHeader["Notlar"].ToString();
            tcBelgeTarihi.Text = drFoyHeader["BelgeTarihi"].ToString();

            DataTable dtDetail = DsFoy.Tables[1];
            string DetailTableName = dtDetail.TableName;

            
            tcGenelToplam.Text = dtDetail.Compute("Sum(SatirToplam)", "").ToString();
            tcToplam.Text = dtDetail.Compute("Sum(tcMetre)", "").ToString()+" mt.";

            this.DataMember = DetailTableName;
            this.DataSource = DsFoy;

            tcKumasKodu.DataBindings.Add("Text", null, DetailTableName + ".tcKumasKodu");
            tcKalite.DataBindings.Add("Text", null, DetailTableName + ".tcKalite");
            tcMetre.DataBindings.Add("Text", null, DetailTableName + ".tcMetre");
            tcBirimFiyat.DataBindings.Add("Text", null, DetailTableName + ".tcBirimFiyat");
            tcToplamTutar.DataBindings.Add("Text", null, DetailTableName + ".tcToplamTutar");
            tcUretici.DataBindings.Add("Text", null, DetailTableName + ".tcUretici");

        }
    }
}